package com.activitycode.adapter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.activitycode.datamodel.OrderDetail;
import com.activitycode.tools.TimeTools;
import com.duostec.zhuyue.taxis.R;

public class RealOrderListAdapter extends BaseAdapter {
    
    public Context context;
    private List<OrderDetail> infoList;
    public final String Tag = "RealOrderListAdapte";
    public RealOrderListAdapter adapter;
    
    public RealOrderListAdapter(Context context, List<OrderDetail> infoList) {
	this.context = context;
	this.infoList = infoList;
	adapter = this;
    }
    @Override
    public int getCount() {
	// TODO Auto-generated method stub
	return this.infoList.size();
    }

    @Override
    public Object getItem(int arg0) {
	// TODO Auto-generated method stub
	return infoList.get(arg0);
    }

    @Override
    public long getItemId(int position) {
	// TODO Auto-generated method stub
	return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
	ViewHolder viewHolder = null;
	if (convertView == null) {
	    viewHolder = new ViewHolder();
	    convertView = LayoutInflater.from(context).inflate(
		    R.layout.realorderlist_row_layout, null);
	    viewHolder.order_time = (TextView) convertView
		    .findViewById(R.id.realorder_time);
//	    viewHolder.state = (TextView) convertView
//		    .findViewById(R.id.realorder_state);
	    
	    viewHolder.container = (LinearLayout) convertView
		    .findViewById(R.id.realorderlist_layout_linear);

	    convertView.setTag(viewHolder);
	} else {

	    viewHolder = (ViewHolder) convertView.getTag();
	}

	/*if (position % 2 == 0) {
	    viewHolder.container.setBackgroundColor(context.getResources()
		    .getColor(R.color.item_bg1));
	} else {
	    viewHolder.container.setBackgroundColor(context.getResources()
		    .getColor(R.color.item_bg2));
	}
	
	
*/	
	
	viewHolder.order_time.setText(""+TimeTools.getOrderTime(infoList.get(position).getOrder_time()));
	//viewHolder.state.setText(infoList.get(position).getState());
	//viewHolder.order_end.setText(infoList.get(position).getOrder_end());

	return convertView;
    }

    public final static class ViewHolder {
   	TextView order_time,state,order_end;
   	LinearLayout container;
       }
}
